package com.lc.recovery.ui.activity.recoveryhome;

import android.os.Bundle;
import android.widget.EditText;

import com.hjq.http.EasyHttp;
import com.hjq.http.listener.HttpCallback;
import com.lc.recovery.R;
import com.lc.recovery.app.AppActivity;
import com.lc.recovery.http.request.AddressSaveApi;
import com.lc.recovery.http.response.PublicMsg;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ReviseActivity extends AppActivity {
    @BindView(R.id.et_content)
    EditText etContent;
    private String address;
    private String id;
    @Override
    protected int getLayoutId() {
        return R.layout.activity_revise;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        address = getIntent().getStringExtra("address");
        id = getIntent().getStringExtra("id");
        etContent.setText(address);
    }

    @OnClick(R.id.tv_revise)
    public void onClick() {
        addressSave();
    }

    private void addressSave() {

            EasyHttp.post(this)
                    .api(new AddressSaveApi().setId(id).setAddress(address)).request(new HttpCallback<PublicMsg>(this) {

                @Override
                public void onSucceed(PublicMsg data) {
                    if (data.getCode() == 200) {
                        toast(data.getMsg());
                    } else {
                        toast(data.getMsg());
                    }


                }


                @Override
                public void onFail(Exception e) {
//                    super.onFail(e);

                }
            });
        }

}
